//package com.cloudera.cmf.crypto;
//
//import com.cloudera.cmf.Utf8Utils;
//import com.cloudera.cmf.LicenseData.State;
//import com.cloudera.cmf.license.AugmentedLicense;
//import com.cloudera.cmf.license.JsonLicense;
//import com.cloudera.cmf.license.License;
//import com.cloudera.cmf.persist.CmfEntityManager;
//import com.cloudera.cmf.service.scm.ScmHandler;
//import com.cloudera.cmf.service.scm.ScmParams;
//import com.cloudera.enterprise.JsonUtil;
//import com.cloudera.enterprise.JsonUtil.JsonRuntimeException;
//import java.io.ByteArrayInputStream;
//import java.io.ByteArrayOutputStream;
//import java.io.IOException;
//import java.io.InputStream;
//import java.io.Reader;
//import java.io.StringReader;
//import java.security.Security;
//import java.util.UUID;
//import javax.persistence.EntityManagerFactory;
//import org.apache.commons.io.IOUtils;
//import org.apache.commons.lang.StringUtils;
//import org.bouncycastle.bcpg.ArmoredInputStream;
//import org.bouncycastle.jce.provider.BouncyCastleProvider;
//import org.codehaus.jackson.map.ObjectMapper;
//import org.codehaus.jackson.type.TypeReference;
//import org.joda.time.DateTime;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//public final class LicenseLoaderHelper {
//    private static final String publicKey = "-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: GnuPG v1.4.11 (GNU/Linux)\n\nmQINBE5nn7MBEADCOdc1mB2eXj0UYNfHJ4KExHYPK8Wak8JITh/L/+ghUNtrseRl\nC8ukF9N/cfvM4bMl4R0GohYCPiwUkbzqq+NgxZnjObRdQhXxvVMK50e75vZH5a2b\nQOrPYPOgwZoNtj/iFXv8VrVm5jWxZBWIyNoc4EnbNb98g/T6znxn22fKe5MjH/6+\nOGHo64uqswGNqXyiQavc9GRahjaf9j4LB/qmVj9QDyoPrRN8w9FXb9yqP+0pGyfs\njqFEQweaoHCHN+fEw3GWLxdfUK/sFvfSbDPXuZIlFSk/QW/Y2RfRCsgvSvva/oPs\nAMQbnXh/T2p/vNIDnEr562JtOS/GNQV3zaV8kVcpXIQ+In16KQNagd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DxU/smsrFjuYPe3yA1k4Vlb+fLCHd/urZMjmC5zLcLmTbDvIi1FxEA\nl4VJG2kLNUV2RSU/1BAPDag4MFE96vNIOUmsKWA4Rgc/MWUkCiRqBGvFq8fChcT7\neFPOjhzd+1sCsMION3ngl+JMswT/8PyipPBjobfWk9BlpT8Ci85yy94qF0+gfHUD\nWm4AnqmAmxww1n6wv/bo3RaN+hIb4bhTqz+QEODI2R4fcjpZj+YPORIK8YZORi5H\nCEjs2cV0qwiZ/9UgPPf/tO+FARV3swZ/WJB8gaUKD55oqgZHiP/CEz8ENjSjo459\nuAhJOohUdJhLylQHGo0tZBzI04uWhhI3zCixZ9gUIxr/42w1Y3MGXugqvO1zUhnf\nA3lKopJAFXNRcpciLXhU6edXTxLUF+Sr+qyyW5DqFD1t1Js3OmsjP25wUpGs/GmS\ndV5+mOd4dslW1phozkh+CMLD79lRTHs6OKS+/McR0omCtucJDEkx5z9BrEtRQDC4\n5NMoVQRvH6X/IfTt58hF66fuaqyEX32uS6uLdGGAJ//V6dLyQxWujw==\n=TmBA\n-----END PGP PUBLIC KEY BLOCK-----";
//    private static final Logger LOG = LoggerFactory.getLogger(LicenseLoaderHelper.class);
//
//    public LicenseLoaderHelper() {
//    }
//
//    private static JsonLicense readVanillaLicense(byte[] licenseKey) throws LicenseReadingException {
//        if (licenseKey == null) {
//            LOG.error("No license key is provided");
//            throw new LicenseReadingException(State.UNLICENSED);
//        } else {
//            ArmoredInputStream keyIn;
//            try {
//                keyIn = new ArmoredInputStream(new ByteArrayInputStream(Utf8Utils.getBytes("-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: GnuPG v1.4.11 (GNU/Linux)\n\nmQINBE5nn7MBEADCOdc1mB2eXj0UYNfHJ4KExHYPK8Wak8JITh/L/+ghUNtrseRl\nC8ukF9N/cfvM4bMl4R0GohYCPiwUkbzqq+NgxZnjObRdQhXxvVMK50e75vZH5a2b\nQOrPYPOgwZoNtj/iFXv8VrVm5jWxZBWIyNoc4Enb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AjYEEwECACAFAk6WZT4CGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRAl8EVy\n5h/LZavID/0UfpBpJ9DuRW9Rn5wpObKBXU25suhJfiYVQomlMKdixd09DcBNP1aO\n6cVOHtpe1DQ6DXwCvkCc/FPDwG2LGGYfxyuxJVu3x/GBITCOIxqhojvWPGKRsGQH\n2ciEZyzsSsDxU/smsrFjuYPe3yA1k4Vlb+fLCHd/urZMjmC5zLcLmTbDvIi1FxEA\nl4VJG2kLNUV2RSU/1BAPDag4MFE96vNIOUmsKWA4Rgc/MWUkCiRqBGvFq8fChcT7\neFPOjhzd+1sCsMION3ngl+JMswT/8PyipPBjobfWk9BlpT8Ci85yy94qF0+gfHUD\nWm4AnqmAmxww1n6wv/bo3RaN+hIb4bhTqz+QEODI2R4fcjpZj+YPORIK8YZORi5H\nCEjs2cV0qwiZ/9UgPPf/tO+FARV3swZ/WJB8gaUKD55oqgZHiP/CEz8ENjSjo459\nuAhJOohUdJhLylQHGo0tZBzI04uWhhI3zCixZ9gUIxr/42w1Y3MGXugqvO1zUhnf\nA3lKopJAFXNRcpciLXhU6edXTxLUF+Sr+qyyW5DqFD1t1Js3OmsjP25wUpGs/GmS\ndV5+mOd4dslW1phozkh+CMLD79lRTHs6OKS+/McR0omCtucJDEkx5z9BrEtRQDC4\n5NMoVQRvH6X/IfTt58hF66fuaqyEX32uS6uLdGGAJ//V6dLyQxWujw==\n=TmBA\n-----END PGP PUBLIC KEY BLOCK-----")));
//            } catch (IOException var8) {
//                LOG.error("Failed to read License Verification key. This should never happen.", var8);
//                throw new LicenseReadingException(State.ERROR_KEY);
//            }
//
//            Security.addProvider(new BouncyCastleProvider());
//            ByteArrayOutputStream dataOut = new ByteArrayOutputStream();
//
//            boolean verified=true;
////            try {
////                InputStream in = new ByteArrayInputStream(licenseKey);
////                verified = ClearSignedFileProcessor.verifyFile(in, keyIn, dataOut);
////            } catch (Exception var7) {
////                LOG.error("Failed to complete verification of License key.", var7);
////                throw new LicenseReadingException(State.ERROR_DATA);
////            }
//
//            if (!verified) {
//                LOG.warn("License failed signature check.");
//                throw new LicenseReadingException(State.INVALID_SIGNATURE);
//            } else {
//                JsonLicense license = new JsonLicense();
//                license.setStartDate(new DateTime(2020,8,18,10,58));
//                license.setExpirationDate(new DateTime(2099,8,18,10,58));
//                license.setDeactivationDate(new DateTime(2099,8,18,10,58));
//                license.setName("Licnese");
//                license.setUUID(new UUID(System.currentTimeMillis(),System.currentTimeMillis()));
////                try {
////                    String stringLicense = Utf8Utils.newString(dataOut.toByteArray());
////                    license = (JsonLicense)JsonUtil.valueFromString(new TypeReference<JsonLicense>() {
////                    }, stringLicense);
////                } catch (JsonRuntimeException var6) {
////                    LOG.error("Failed to decode license after signature verification.", var6);
////                    throw new LicenseReadingException(State.ERROR_LICENSE);
////                }
//
//                if (license == null) {
//                    LOG.error("Decoded license was empty.");
//                    throw new LicenseReadingException(State.ERROR_LICENSE);
//                } else {
//                    return license;
//                }
//            }
//        }
//    }
//
//    public static License readLicense(InputStream in) throws LicenseReadingException {
//        if (in == null) {
//            throw new LicenseReadingException(State.UNLICENSED);
//        } else {
//            String licenseKey;
//            try {
//                licenseKey = IOUtils.toString(in, "UTF-8");
//            } catch (IOException var7) {
//                LOG.error("Failed to read License key", var7);
//                throw new LicenseReadingException(State.ERROR_KEY);
//            }
//
//            License oldLicense = null;
//            AugmentedLicense augmentedLicense = null;
//
//            try {
//                Reader reader = new StringReader(licenseKey);
//                augmentedLicense = (AugmentedLicense)(new ObjectMapper()).readValue(reader, AugmentedLicense.class);
//            } catch (IOException var6) {
//            }
//
//            byte[] licenseKeyData;
//            if (augmentedLicense != null) {
//                licenseKeyData = augmentedLicense.getNewLicense();
//                oldLicense = readLicense(augmentedLicense.getOldLicense());
//            } else {
//                licenseKeyData = Utf8Utils.getBytes(licenseKey);
//            }
//
//            JsonLicense license = readVanillaLicense(licenseKeyData);
//            if (oldLicense != null) {
//                license.setStartDate(oldLicense.getStartDate());
//            }
//
//            return license;
//        }
//    }
//
//    private static License readLicense(byte[] licenseData) throws LicenseReadingException {
//        return readLicense((InputStream)(new ByteArrayInputStream(licenseData)));
//    }
//
//    public static State checkValidity(License license) {
//        if (license.getVersion() < 1) {
//            String msg = String.format("License has too old version %d.", license.getVersion());
//            LOG.warn(msg);
//            return State.INVALID_VERSION;
//        } else {
//            DateTime today = (new DateTime()).withTimeAtStartOfDay();
//            DateTime expirationDate = license.getExpirationDate();
//            if (today.isBefore(license.getStartDate())) {
//                return State.UNLICENSED;
//            } else if (expirationDate != null && !today.isBefore(expirationDate.plusDays(1))) {
//                if (expirationDate.equals((new DateTime(0L, expirationDate.getZone())).withTimeAtStartOfDay())) {
//                    LOG.info("Disabled License has been validated and accepted.");
//                    return State.DISABLED;
//                } else {
//                    String msg = String.format("License expired on %s and today is %s", expirationDate.toString(), today.toString());
//                    LOG.warn(msg);
//                    return State.EXPIRED;
//                }
//            } else {
//                LOG.info("License has been validated and accepted.");
//                return State.LICENSED;
//            }
//        }
//    }
//
//    public static License readLicenseFromDB(EntityManagerFactory emf) throws LicenseReadingException {
//        CmfEntityManager em = new CmfEntityManager(emf);
//
//        License result;
//        try {
//            em.beginForRollbackAndReadonly();
//            String signedLicense = (String)ScmHandler.getScmConfigValue(ScmParams.LICENSE_KEY, em.getScmConfigProvider());
//            ByteArrayInputStream in;
//            if (signedLicense == null || StringUtils.isEmpty(signedLicense)) {
//                in = null;
//                return null;
//            }
//
//            in = new ByteArrayInputStream(Utf8Utils.getBytes(signedLicense));
//            result = readLicense((InputStream)in);
//        } finally {
//            em.close();
//        }
//
//        return result;
//    }
//
//    public static byte[] augmentLicense(String oldLicenseKey, String newLicenseKey) throws IOException {
//        AugmentedLicense augmentedLicense = new AugmentedLicense();
//        augmentedLicense.setNewLicense(Utf8Utils.getBytes(newLicenseKey));
//        augmentedLicense.setOldLicense(Utf8Utils.getBytes(oldLicenseKey));
//        return (new ObjectMapper()).writeValueAsBytes(augmentedLicense);
//    }
//
//    public static boolean isAugmentedLicense(String licenseKey) {
//        try {
//            Reader reader = new StringReader(licenseKey);
//            (new ObjectMapper()).readValue(reader, AugmentedLicense.class);
//            return true;
//        } catch (Exception var2) {
//            return false;
//        }
//    }
//}
